<template>
  <view class="w-full  h-80px text-18px" :class="isApp ? 'pt-10' : 'pt-10'">
    <view v-if="isBack" class=" flex relative z-11 flex flex-col">
      <view class="text-lg tracking-wider flex justify-center relative" :style="isWhite ? 'color:#ffffff' : 'color:#000000'">
        <view class=" absolute left-32rpx" @click="goBack" ><u-icon name="arrow-left" /></view>
        <view class="col-span-1 text-center">{{ props.title }}</view>
      </view>
    </view>
    <view v-else class="px-4  relative z-11 flex flex-col w-full text-center">
      <view class="  text-lg font-500 tracking-wider w-full" :style="isWhite ? 'color:#ffffff' : 'color:#000000'">{{ props.title }}</view>
    </view>
  </view>
</template>

<script setup lang="ts">

const props = withDefaults(defineProps<{
  title: string,
  isWhite?: boolean,
  isBack?: boolean,
  height?: number,
  isApp?: boolean,
}>(), {
  title: '',
  isWhite: true, // 是否白色标题
  isBack: false, // 是否显示返回按钮
  height: 600, // 高度
  isApp: false, // 是否是app
})

/**
 * 返回上一页
 */
async function goBack() {
  const pages = getCurrentPages()
  if (pages.length === 1) {
    // 只有一个页面时，跳转到首页或你想去的页面
    uni.switchTab({
      url: '/pages/index/index',
    })
  } else {
    uni.navigateBack()
  }
}

</script>

<style scoped>

</style>
